﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Ordering.Domain.AggregatesModel.OrderAggregate;
using System;
using System.Collections.Generic;
using System.Text;

namespace Ordering.Infrastructure.EntityConfigurations
{
    class OrderItemEntityTypeConfiguration
                : IEntityTypeConfiguration<OrderItem>
    {
        public void Configure(EntityTypeBuilder<OrderItem> builder)
        {
            builder.ToTable("orderitem", OrderingContext.DEFAULT_SCHEMA);

            builder.HasKey(ci => ci.Id);

            builder.Property(ci => ci.Id)
               .UseHiLo("orderitemseq", OrderingContext.DEFAULT_SCHEMA)
               .IsRequired();
            builder.Property(cb => cb.OrderId)
                .IsRequired(true);
            builder.Property(cb => cb.ProductCode)
                .HasMaxLength(50)
                .IsRequired(true);
            builder.Property(cb => cb.ProductPrice)
                .IsRequired(true);
            builder.Property(cb => cb.ProductName)
                .IsRequired(true);
            builder.Property(cb => cb.ExtendField)
                .IsRequired(false);
            builder.Property(cb => cb.ExtendField2)
                .IsRequired(false);
            builder.Property(cb => cb.Num)
                .IsRequired(true);
            builder.Property(cb => cb.Remark)
                .IsRequired(false);
        }
    }
}
